﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Gene_Explorer_Client
{
    public partial class OrderWizardValidation : Form
    {
        public bool radioButtonVCFlag = false;
        public bool radioButtonFlag = true;

        public OrderWizardValidation()
        {
            InitializeComponent();
        }

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button_Back_Click(object sender, EventArgs e)
        {
            GlobalVariable.orderWV = this;
            this.Hide();
            OrderWizardCluster oWC = new OrderWizardCluster();
            oWC = GlobalVariable.orderWC;
            oWC.Show();
            
            
        }

        private void button_Next_Click(object sender, EventArgs e)
        {
            string _str1;   //第1步参数收集
            string _str2;   //第2步参数收集
            string _str2_1; //第2步过滤参数收集
            string _str2_2; //第2步估值参数收集
            string _str2_3; //第2步转换参数收集
            string _str2_4; //第2步PCA参数收集
            string _str3;   //第3步参数收集
            string _str4;   //第4步参数收集
            string _str5;   //第5步参数收集
            GlobalVariable.orderWV = this;
            
            _str1 = "1.选择数据集：\n" + "文件" + "fileName" + "，进行实验数据："
                    + (GlobalVariable.orderWSD.radioButton_All.Checked ? "所有行与列" : "")
                    + (GlobalVariable.orderWSD.radioButton_ExceptOne.Checked ? "除去第1行与第1列" : "")
                    + (GlobalVariable.orderWSD.radioButton_RowColumn.Checked ? "从第" 
                    + GlobalVariable.orderWSD.textBox_RowInf.Text + "行到第" 
                    + GlobalVariable.orderWSD.textBox_RowSup.Text + "行，从第" 
                    + GlobalVariable.orderWSD.textBox_ColumnInf.Text + "列到第" 
                    + GlobalVariable.orderWSD.textBox_ColumnSup.Text + "列" : "")
                    + (GlobalVariable.orderWSD.checkBox_Classification.Checked ? "，已有分类参考在数据集中的列数:第" 
                    + GlobalVariable.orderWSD.textBox_Classification.Text + "列"
                    + "，已有分类将数据分为" + GlobalVariable.orderWSD.textBox_ClassNum.Text + "类" : "") + "；\n";
            
            _str2_1 = "\n" + "2.过滤数据集：\n" + (GlobalVariable.orderWDP.checkBox_Filtering.Checked ?
                      (GlobalVariable.orderWDP.checkBox_LosePercent.Checked ? "行过滤：" + "数据损失百分比大于" 
                      + GlobalVariable.orderWDP.textBox_LosePercent.Text + "%" : "")
                      + (GlobalVariable.orderWDP.checkBox_MinSD.Checked ? "标准差小于"
                      + GlobalVariable.orderWDP.textBox_MinSD.Text +  "，" : "")
                      + (GlobalVariable.orderWDP.checkBox_Entropy.Checked ? "熵小于"
                      + GlobalVariable.orderWDP.textBox_Entropy.Text + "，" : "")
                      + (GlobalVariable.orderWDP.checkBox_MaxMin.Checked ? "表达幅度小于"
                      + GlobalVariable.orderWDP.textBox_MaxMin.Text + "，" : "")
                      + (GlobalVariable.orderWDP.checkBox_Threshold.Checked ? "数据点绝对值未达到阈值" 
                      + GlobalVariable.orderWDP.textBox_Threshold.Text + "的数量大于"
                      + GlobalVariable.orderWDP.textBox_Number.Text + "，" : "")
                      + (GlobalVariable.orderWDP.checkBox_EmptyGene.Checked ? "删除空基因数据" : "")
                      + "；\n": "");
            
            _str2_2 = (GlobalVariable.orderWDP.checkBox_Imputation.Checked ?
                       "点估值：估值算法:" + (GlobalVariable.orderWDP.comboBox_InputationMethod.SelectedIndex == 0 ? "删除该行"
                      : (GlobalVariable.orderWDP.comboBox_InputationMethod.SelectedIndex == 1 ? "设置为列平均值" : "")
                      + (GlobalVariable.orderWDP.comboBox_InputationMethod.SelectedIndex == 2 ? "设置为行平均值" : "")
                      + (GlobalVariable.orderWDP.comboBox_InputationMethod.SelectedIndex == 3 ? "K最近邻(KNN)" : "")
                      + (GlobalVariable.orderWDP.comboBox_AverageMethod.SelectedIndex == 0 ? "，平均值算法：均值" : "")
                      + (GlobalVariable.orderWDP.comboBox_AverageMethod.SelectedIndex == 1 ? "，平均值算法：中值" : "")
                      + (GlobalVariable.orderWDP.comboBox_InputationMethod.SelectedIndex == 3 ? "，近邻数量:" 
                      + GlobalVariable.orderWDP.textBox_K.Text + "，度量距离：" 
                      + (GlobalVariable.orderWDP.comboBox_DistanceMeasure.SelectedIndex == 0 ? "Euclidean" : "")
                      + (GlobalVariable.orderWDP.comboBox_DistanceMeasure.SelectedIndex == 1 ? "Manhattan" : "")
                      + (GlobalVariable.orderWDP.comboBox_DistanceMeasure.SelectedIndex == 2 ? "Minkowski"
                      + "，Minkowski距离指数：" + GlobalVariable.orderWDP.comboBox_Power.Text : "")
                      + (GlobalVariable.orderWDP.comboBox_DistanceMeasure.SelectedIndex == 3 ? "Chebychev" : "")
                      + (GlobalVariable.orderWDP.comboBox_DistanceMeasure.SelectedIndex == 4 ? "Pearson" : "") : ""))
                      + "；\n" : "");
            
            _str2_3 = (GlobalVariable.orderWDP.checkBox_Transformation.Checked ? "转换：" 
                      + (GlobalVariable.orderWDP.radioButton_Norm.Checked ? "标准化数据" : "")
                      + (GlobalVariable.orderWDP.radioButton_Log.Checked ?
                      (GlobalVariable.orderWDP.comboBox_Log.SelectedIndex == 0 ? "log2" : "")
                      + (GlobalVariable.orderWDP.comboBox_Log.SelectedIndex == 1 ? "log10" : "")
                      + (GlobalVariable.orderWDP.comboBox_Log.SelectedIndex == 2 ? "ln" : "")
                      + (GlobalVariable.orderWDP.comboBox_Log.SelectedIndex == 3 ? "logx" + "，X:"
                      + (GlobalVariable.orderWDP.textBox_X.Text) : "") : "")
                      + "；\n" : "");
            
            _str2_4 = (GlobalVariable.orderWDP.checkBox_PCA.Checked ? "主成分分析；" + "\n" : "");
            
            _str2 = _str2_1 + _str2_2 + _str2_3 + _str2_4;
            
            _str3 = "\n" + "3.选择聚类算法：\n"
                   + (GlobalVariable.orderWC.checkBox_FCM.Checked ? "FCM:聚类数：" 
                   + GlobalVariable.orderWC.textBox_FCMCluster.Text + "，迭代次数：" 
                   + GlobalVariable.orderWC.textBox_FCMCount.Text + "；\n" : "")
                   + (GlobalVariable.orderWC.checkBox_GMM.Checked ? "GMM:聚类数：" 
                   + GlobalVariable.orderWC.textBox_GMMCluster.Text + "，模型类型：" 
                   + GlobalVariable.orderWC.comboBox_Modeltype.Text + "，训练次数：" 
                   + GlobalVariable.orderWC.textBox_EMTimes.Text + "；\n" : "")
                   + (GlobalVariable.orderWC.checkBox_Hierachical.Checked ? "Hierachical:聚类数：" 
                   + GlobalVariable.orderWC.textBox_HierachicalCluster.Text + "，簇间聚类度量：" 
                   + GlobalVariable.orderWC.comboBox_ClusterDistance.Text + "，距离度量：" 
                   + GlobalVariable.orderWC.comboBox_Measuredistance.Text 
                   + (GlobalVariable.orderWC.comboBox_Measuredistance.SelectedIndex == 2 ? "，Minkowski距离指数：" 
                   + GlobalVariable.orderWC.comboBox_Power1.Text : "") + "；\n" : "")
                   + (GlobalVariable.orderWC.checkBox_Kmeans.Checked ? "K-means:聚类数：" 
                   + GlobalVariable.orderWC.textBox_KmeansCluster.Text + "，初始化质心：" 
                   + GlobalVariable.orderWC.comboBox_KmeansInimethod.Text + "，距离度量："
                   + GlobalVariable.orderWC.comboBox_KmeansMeasuredistance.Text
                   /*+ (GlobalVariable.orderWC.comboBox_KmeansMeasuredistance.SelectedIndex == 2 ? "，Minkowski距离指数：" 
                   + GlobalVariable.orderWC.comboBox_Power2.Text : "")*/ + "；\n" : "")
                   + (GlobalVariable.orderWC.checkBox_SOM.Checked ? "SOM:拓扑：" 
                   + GlobalVariable.orderWC.comboBox_SOMTopology.Text + "，行数：" 
                   + GlobalVariable.orderWC.textBox_SOMRow.Text + "，列数：" 
                   + GlobalVariable.orderWC.textBox_SOMColumn.Text /*+ "，迭代次数：" 
                   + GlobalVariable.orderWC.textBox_SOMIteratetime.Text*/ + "，距离度量：" 
                   + GlobalVariable.orderWC.comboBox_SOMMeasuredistance.Text
                   /*+ (GlobalVariable.orderWC.comboBox_SOMMeasuredistance.SelectedIndex ==2 ? "，Minkowski距离指数：" 
                   //+ GlobalVariable.orderWC.comboBox_Power3.Text : "")*/ + "；" : "") + "\n";

            _str4 = "\n" + "4.选择有效性验证：\n"
                   + (GlobalVariable.orderWV.radioButton_Validation.Checked ? "聚类算法有效性验证：\n" 
                   + (GlobalVariable.orderWV.checkBox_ARI.Checked? "ARI，":"") 
                   + (GlobalVariable.orderWV.checkBox_FOM.Checked? "FOM,":"")
                   + (GlobalVariable.orderWV.checkBox_RI.Checked? "RI；":"")
                   + (GlobalVariable.orderWV.checkBox_Silhouette.Checked ? "Silhouette(" 
                   + "距离度量：" + GlobalVariable.orderWV.comboBox_SilhouetteDM.Text + ")"
                   /*+ (GlobalVariable.orderWV.comboBox_SilhouetteDM.SelectedIndex == 2 ? "，Minkowski距离指数：" 
                   + GlobalVariable.orderWV.comboBox_Power1.Text : "")*/ : "") : "")
                   + (GlobalVariable.orderWV.radioButton_ValiadationCompare.Checked ? "聚类算法有效性对比分析:\n" 
                   + (GlobalVariable.orderWV.checkBox_CompareARI.Checked ? "ARI(" 
                   + GlobalVariable.orderWV.textBox_ARIInf.Text + " to " 
                   + GlobalVariable.orderWV.textBox_ARISup.Text + ")," :"") 
                   + (GlobalVariable.orderWV.checkBox_CompareFOM.Checked ? "FOM(" 
                   + GlobalVariable.orderWV.textBox_FOMInf.Text + " to " 
                   + GlobalVariable.orderWV.textBox_FOMSup.Text + "),":"")
                   + (GlobalVariable.orderWV.checkBox_CompareRI.Checked ? "RI(" 
                   + GlobalVariable.orderWV.textBox_RIInf.Text + " to " 
                   + GlobalVariable.orderWV.textBox_RISup.Text + ")；":"")
                   + (GlobalVariable.orderWV.checkBox_CompareSilhouette.Checked ? "Silhouette(" 
                   + GlobalVariable.orderWV.textBox_SilhouetteInf.Text + " to " 
                   + GlobalVariable.orderWV.textBox_SilhouetteSup.Text + "," 
                   + "距离度量：" + GlobalVariable.orderWV.comboBox_CompareSilhouetteDM.Text + ")"
                   /*+ (GlobalVariable.orderWV.comboBox_CompareSilhouetteDM.SelectedIndex == 2 ? "，Minkowski距离指数：" 
                   + GlobalVariable.orderWV.comboBox_Power2.Text : "")*/ : "") : "") + "；";

            _str5 = _str1 + _str2 + _str3 + _str4;
            this.Hide();
            OrderWizardSummary oWS = new OrderWizardSummary();
            oWS.richTextBox.Text = _str5;
            oWS.ShowDialog();
            
        }

        private void OrderWizardValidation_Load(object sender, EventArgs e)
        {

        }

        private void radioButton_Validation_CheckedChanged(object sender, EventArgs e)
        {
            //comboBox_SilhouetteDM  checkBox_ARI  checkBox_FOM  checkBox_RI  checkBox_Silhouette  label10

            if (GlobalVariable.orderWSD.checkBox_Classification.Checked)
            {
                checkBox_ARI.Enabled = !checkBox_ARI.Enabled;
                checkBox_RI.Enabled = !checkBox_RI.Enabled; 
            }
            checkBox_FOM.Enabled = !checkBox_FOM.Enabled;
            checkBox_Silhouette.Enabled = !checkBox_Silhouette.Enabled;
            //label10.Enabled = !label10.Enabled;
            // comboBox_SilhouetteDM.Enabled = !comboBox_SilhouetteDM.Enabled;
            if (checkBox_Silhouette.Checked == true)
            {
                label10.Enabled = !label10.Enabled;
                comboBox_SilhouetteDM.Enabled = !comboBox_SilhouetteDM.Enabled;
                if (comboBox_SilhouetteDM.SelectedIndex == 2)
                {
                    label18.Enabled = !label18.Enabled;
                    comboBox_Power1.Enabled = !comboBox_Power1.Enabled;
                }
            }
            /*
            if (radioButtonFlag == false)
            {
                comboBox_SilhouetteDM.Enabled = true;
                checkBox_ARI.Enabled = true;
                checkBox_FOM.Enabled = true;
                checkBox_RI.Enabled = true;
                checkBox_Silhouette.Enabled = true;
                label10.Enabled = true;
                if (comboBox_SilhouetteDM.SelectedIndex == 2)
                {
                    label18.Enabled = true;
                    comboBox_Power1.Enabled = true;
                }
            }
            else
            {
                comboBox_SilhouetteDM.Enabled = false;
                checkBox_ARI.Enabled = false;
                checkBox_FOM.Enabled = false;
                checkBox_RI.Enabled = false;
                checkBox_Silhouette.Enabled = false;
                label10.Enabled = false;
                if (comboBox_SilhouetteDM.SelectedIndex == 2)
                {
                    label18.Enabled = false;
                    comboBox_Power1.Enabled = false;
                }
            }
            radioButtonFlag = !radioButtonFlag;
             */ 
        }

        private void radioButton_ValiadationCompare_CheckedChanged(object sender, EventArgs e)
        {
            //checkBox_CompareARI  checkBox_CompareARI  checkBox_CompareFOM  checkBox_CompareRI  checkBox_CompareSilhouette
            //label1 to label9
            //textBox_ARIInf textBox_ARISup  textBoxFOMInf  textBoxFOMSup  textBox_RIInf  textBox_RISup  textBox_SilhouetteInf  textBox_SilhouetteSup  comboBox_CompareSilhouetteDM

            if (GlobalVariable.orderWSD.checkBox_Classification.Checked)
            {
                checkBox_CompareARI.Enabled = !checkBox_CompareARI.Enabled;
                checkBox_CompareRI.Enabled = !checkBox_CompareRI.Enabled;
            }
            checkBox_CompareFOM.Enabled = !checkBox_CompareFOM.Enabled;
            checkBox_CompareSilhouette.Enabled = !checkBox_CompareSilhouette.Enabled;
            if (checkBox_CompareARI.Checked == true)
            {
                label1.Enabled = !label1.Enabled;
                label5.Enabled = !label5.Enabled;
                textBox_ARIInf.Enabled = !textBox_ARIInf.Enabled;
                textBox_ARISup.Enabled = !textBox_ARISup.Enabled;
            }
            if (checkBox_CompareFOM.Checked == true)
            {
                label2.Enabled = !label2.Enabled;
                label6.Enabled = !label6.Enabled;
                textBox_FOMInf.Enabled = !textBox_FOMInf.Enabled;
                textBox_FOMSup.Enabled = !textBox_FOMSup.Enabled;
            }
            if (checkBox_CompareRI.Checked == true)
            {
                label3.Enabled = !label3.Enabled;
                label7.Enabled = !label7.Enabled;
                textBox_RIInf.Enabled = !textBox_RIInf.Enabled;
                textBox_RISup.Enabled = !textBox_RISup.Enabled;
            }
            if (checkBox_CompareSilhouette.Checked == true)
            {
                label4.Enabled = !label4.Enabled;
                label8.Enabled = !label8.Enabled;
                label9.Enabled = !label9.Enabled;

                textBox_SilhouetteInf.Enabled = !textBox_SilhouetteInf.Enabled;
                textBox_SilhouetteSup.Enabled = !textBox_SilhouetteSup.Enabled;
                comboBox_CompareSilhouetteDM.Enabled = !comboBox_CompareSilhouetteDM.Enabled;
                if (comboBox_CompareSilhouetteDM.SelectedIndex == 2)
                {
                    label11.Enabled = !label11.Enabled;
                    comboBox_Power2.Enabled = !comboBox_Power2.Enabled;
                }
            }
            
            //if (checkBox_CompareSilhouette.Checked == true)
            //{
            //    label9.Enabled = !label9.Enabled;
            //    comboBox_CompareSilhouetteDM.Enabled = !comboBox_CompareSilhouetteDM.Enabled;
            //    if (comboBox_CompareSilhouetteDM.SelectedIndex == 2)
            //    {
            //        label11.Enabled = !label11.Enabled;
            //        comboBox_Power2.Enabled = !comboBox_Power2.Enabled;
            //    }
            //}
            /*
            if (radioButtonVCFlag == false)
            {
                checkBox_CompareARI.Enabled = true;
                checkBox_CompareARI.Enabled = true;
                checkBox_CompareFOM.Enabled = true;
                checkBox_CompareRI.Enabled = true;
                checkBox_CompareSilhouette.Enabled = true;
                label1.Enabled = true;
                label2.Enabled = true;
                label3.Enabled = true;
                label4.Enabled = true;
                label5.Enabled = true;
                label6.Enabled = true;
                label7.Enabled = true;
                label8.Enabled = true;
                label9.Enabled = true;
                textBox_ARIInf.Enabled = true;
                textBox_ARISup.Enabled = true;
                textBox_FOMInf.Enabled = true;
                textBox_FOMSup.Enabled = true;
                textBox_RIInf.Enabled = true;
                textBox_RISup.Enabled = true;
                textBox_SilhouetteInf.Enabled = true;
                textBox_SilhouetteSup.Enabled = true;
                comboBox_CompareSilhouetteDM.Enabled = true; 
            }
            else
            {
                checkBox_CompareARI.Enabled = false;
                checkBox_CompareARI.Enabled = false;
                checkBox_CompareFOM.Enabled = false;
                checkBox_CompareRI.Enabled = false;
                checkBox_CompareSilhouette.Enabled = false;
                label1.Enabled = false;
                label2.Enabled = false;
                label3.Enabled = false;
                label4.Enabled = false;
                label5.Enabled = false;
                label6.Enabled = false;
                label7.Enabled = false;
                label8.Enabled = false;
                label9.Enabled = false;
                textBox_ARIInf.Enabled = false;
                textBox_ARISup.Enabled = false;
                textBox_FOMInf.Enabled = false;
                textBox_FOMSup.Enabled = false;
                textBox_RIInf.Enabled = false;
                textBox_RISup.Enabled = false;
                textBox_SilhouetteInf.Enabled = false;
                textBox_SilhouetteSup.Enabled = false;
                comboBox_CompareSilhouetteDM.Enabled = false; 
            }
            radioButtonVCFlag = !radioButtonVCFlag;
             */ 
        }

        private void comboBox_CompareSilhouetteDM_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox_CompareSilhouetteDM.SelectedIndex == 2)
            {
                label11.Enabled = true;            
                comboBox_Power2.Enabled = true;
            }
            else
            {
                label11.Enabled = false;
                comboBox_Power2.Enabled = false;
            }
        }


        private void comboBox_SilhouetteDM_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox_SilhouetteDM.SelectedIndex == 2)
            {
                label18.Enabled = true;
                comboBox_Power1.Enabled = true;
            }
            else
            {
                label18.Enabled = false;
                comboBox_Power1.Enabled = false;
            }
            
        }

        private void checkBox_Silhouette_CheckedChanged(object sender, EventArgs e)
        {
            label10.Enabled = !label10.Enabled;
            comboBox_SilhouetteDM.Enabled = !comboBox_SilhouetteDM.Enabled;
            if (comboBox_SilhouetteDM.SelectedIndex == 2)
            {
                label18.Enabled = !label18.Enabled;
                comboBox_Power1.Enabled = !comboBox_Power1.Enabled;
            }
        }

        private void checkBox_CompareARI_CheckedChanged(object sender, EventArgs e)
        {
            label1.Enabled = !label1.Enabled;
            label5.Enabled = !label5.Enabled;
            textBox_ARIInf.Enabled = !textBox_ARIInf.Enabled;
            textBox_ARISup.Enabled = !textBox_ARISup.Enabled;
        }

        private void checkBox_CompareFOM_CheckedChanged(object sender, EventArgs e)
        {
            label2.Enabled = !label2.Enabled;
            label6.Enabled = !label6.Enabled;
            textBox_FOMInf.Enabled = !textBox_FOMInf.Enabled;
            textBox_FOMSup.Enabled = !textBox_FOMSup.Enabled;
        }

        private void checkBox_CompareRI_CheckedChanged(object sender, EventArgs e)
        {
            label3.Enabled = !label3.Enabled;
            label7.Enabled = !label7.Enabled;
            textBox_RIInf.Enabled = !textBox_RIInf.Enabled;
            textBox_RISup.Enabled = !textBox_RISup.Enabled;
        }

        private void checkBox_CompareSilhouette_CheckedChanged(object sender, EventArgs e)
        {
            label4.Enabled = !label4.Enabled;
            label8.Enabled = !label8.Enabled;
            label9.Enabled = !label9.Enabled;
            
            textBox_SilhouetteInf.Enabled = !textBox_SilhouetteInf.Enabled;
            textBox_SilhouetteSup.Enabled = !textBox_SilhouetteSup.Enabled;
            comboBox_CompareSilhouetteDM.Enabled = !comboBox_CompareSilhouetteDM.Enabled;
            if (comboBox_CompareSilhouetteDM.SelectedIndex == 2)
            {
                label11.Enabled = !label11.Enabled;
                comboBox_Power2.Enabled = !comboBox_Power2.Enabled;
            }
        }

        private void textBox_ARIInf_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_ARISup_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_FOMInf_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_FOMSup_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_RIInf_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_RISup_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_SilhouetteInf_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }

        private void textBox_SilhouetteSup_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
            if (e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }
    }
}
